/**
 * 
 */
package sw.opencl;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Chung
 *
 */
public class DiagonalMatrix {
	
	public int min(int a, int b, int c) {
		return Math.min(a, Math.min(b, c));
	}
	
	public void compute(int row, int col, int sub) {

		row = row / sub;
		col = col / sub;
		
	    for (int line=1; line<=(row + col -1); line++)
	    {
	        /* Get column index of the first element in this line of output.
	           The index is 0 for first ROW lines and line - ROW for remaining
	           lines  */
	        int start_col =  Math.max(0, line-row);
	 
	        // number of diagonals of matrix
	        int subLength = min(line, (col-start_col), row);
	        int[] subIndexes = new int[subLength*2];

	        /* store coordinates of cells on the same diagonal */
	        for (int j=0; j< subLength; j++) {
	        	subIndexes[2*j] = (Math.min(row, line)-j-1)*sub;;
	        	subIndexes[2*j+1] = (start_col+j)*sub;;
	        }
	    }
	}
	
	public static void main(String[] args) {
		DiagonalMatrix diagonalMatrix = new DiagonalMatrix();
		diagonalMatrix.compute(6, 6, 3);
//		System.out.println(diagonalMatrix.getGreatestDivisor(1000, 1000)); 
	}
	
}
